package com.yuanxiao.mapper;

import com.yuanxiao.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * @author yuaxiao
 * @date 2020/8/23 11:25 上午
 * @description
 */
@Mapper
public interface OrderMapper {
    @Select("select id, name, count, status, cancelReason , orderTime  from t_order where id = #{id}")
    Order getOrderById(String id);

    @Select("select id, name, count, status, cancelReason , orderTime  from t_order")
    List<Order> getOrders();

    @Insert({"insert into t_order (id, name, count, status, cancelReason, orderTime)" +
            " values(#{id}, #{name}, #{count}, #{status}, #{cancelReason}, #{orderTime})"})
    Integer addOrder(Order order);

    @Update({"update t_order set status=#{status}, cancelReason=#{cancelReason} where id = #{id}"})
    Integer updateOrderStatusById(String id, String status, String cancelReason);
}
